import java.util.Arrays;
import java.util.Comparator;
import java.util.Locale;

public class Leet748 {
    public static void main(String[] args) {
        String[] strings = new String[]{"step","steps","stripe","stepple"};

        Leet748 l = new Leet748();
        System.out.println(l.shortestCompletingWord("1s3 PSt",strings));
    }
    public String shortestCompletingWord(String licensePlate, String[] words) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < licensePlate.length(); i++) {
            if ((licensePlate.charAt(i)<='z'&&licensePlate.charAt(i)>='a')||(licensePlate.charAt(i)<='Z'&&licensePlate.charAt(i)>='A')){
                sb.append(licensePlate.charAt(i));
            }
        }
        licensePlate = sb.toString().toLowerCase();
        Arrays.sort(words,(Comparator.comparingInt(String::length)));
        b:
        for (String word : words) {
            for (int j = 0; j < licensePlate.length(); j++) {
                if (!word.contains(String.valueOf(licensePlate.charAt(j))))
                    continue b;
            }
            return word;
        }
        return "";
    }
}
